/**
 * create by young (young2f@outlook.com) on 2020/12/4
 * 这个出库批次是商品的批次，不是原料的，原料的在storeLot里
 */
'use strict';
const model = require('../base/modelBase');
const _ = require('lodash');
module.exports = app => {
  const mongoose = app.mongoose;
  const schema = mongoose.Schema;
  const connect = app.mongooseDB.get('pmcBus');
  const json = {
    lotType: {
      type: 'string', _type: 'string', title: '入库类型', enableArea: []
    },
    lotCode: {
      type: 'string', _type: 'string', title: '批次编码', required: true, enableArea: []
    },
    name: {
      type: 'string', _type: 'string', title: '物料编码', enableArea: []
    },
    division: {
      type: 'string', _type: 'string', title: '销售公司', enableArea: [
        'input',
        'detail',
      ]
    },
    prodName: {
      type: 'string', _type: 'string', table: 'material', title: '品名', enableArea: [
        'table', 'input',
        'detail',
        'search'
      ]
    },
    prodCode: {
      type: 'string', _type: 'string', title: '编号', enableArea: [
        'table', 'input',
        'detail',
      ]
    },
    orderCode: {
      type: 'string',
      inputType: 'input',
      table: 'material',
      title: '订单编码',
      required: true,
      disabled: true,
      enableArea: [
        'detail',
        'search'
      ]
    },

    outboundDate: {
      type: Date, _type: 'string', title: '出库日期', enableArea: [
        'table',
        'detail',
        'search'
      ]
    },
    outboundCount: {
      type: 'number', _type: 'string', title: '出库数量', enableArea: [
        'table', 'input',
        'detail',
        'search'
      ]
    },

    price: { type: 'number', _type: 'number', title: '商品包装', enableArea: [ 'search' ] },
    shippingFee: { type: 'number', _type: 'number', title: '运费', enableArea: [ 'search', 'table', ] },
    pkg: { type: 'string', _type: 'string', title: '商品包装', enableArea: [ 'search' ] },
    customer: { type: 'string', _type: 'string', title: '客户', enableArea: [ 'search', 'table', ] },
    customerCode: { type: 'string', _type: 'string', title: '客户编码', enableArea: [ 'search' ] },
    materials: { type: 'array', _type: 'array', title: '物料', enableArea: [] },

    deliverWay: {
      type: 'string', _type: 'select', title: '商品发货方式', enableArea: [ 'search', 'table', ], options: [
        '直发',
        '仓库',
        '业务员送',
        '客户自提'
      ]
    },
    deliverChannel: { type: 'string', _type: 'string', title: '商品送货渠道', enableArea: [ 'search', 'table', ] },
    fileList: {
      type: Array, _type: 'array', title: '附件', enableArea: []
    },
  };
  const _model = _.cloneDeep(model);
  _.assign(_model, json);
  const _schema = new schema(
    _model,
    { timestamps: { createdAt: 'createdTs', updatedAt: 'updatedTs' } }
  );
  _schema.index({ 'code': 1 });
  return connect.model('OutboundLot', _schema);
};
/**
 current: { type: 'number' },
 voltage: { type: 'number' },
 activePower: { type: 'number' },
 positiveActiveEnergy: { type: 'number' },
 ReverseActiveEnergy: { type: 'number' },
 currentA: { type: 'number' },
 currentB: { type: 'number' },
 currentC: { type: 'number' },
 voltageA: { type: 'number' },
 voltageB: { type: 'number' },
 voltageC: { type: 'number' },
 */
